package com.lw.vue_shop_server.service.impl;

import com.lw.vue_shop_server.mapper.PermissionMapper;
import com.lw.vue_shop_server.po.Permission;
import com.lw.vue_shop_server.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    public PermissionMapper permissionMapper;

    @Override
    public Map getrights(String type) {
        Map<String,Object> result = new HashMap<>();
        Map<String,Object> meta = new HashMap<>();
        if ("list".equals(type)){
            List<Permission> rights = permissionMapper.getrights();
            if(rights != null){
                result.put("data",rights);
                meta.put("msg","查询成功");
                meta.put("status",200);
            }else {
                meta.put("msg","查询失败");
                meta.put("status",501);
            }
            result.put("meta",meta);
            return result;
        }
        return null;
    }
}
